#ifndef XOSECTION_H
#define XOSECTION_H

#include "FKObject3D.h"
#include "XOEvent.h"

#define X_OWNER -1
#define O_OWNER 1
#define NO_OWNER 0

class FK_OBJECT(XOSection,FKObject3D)
    Q_OBJECT
	Q_PROPERTY(QPoint C_COORD READ getCoord WRITE c_coord)
	Q_PROPERTY(qint8 C_OWNER READ getOwner WRITE c_owner)
public:
    void setCoord(const QPoint& v){if(servant)servant->coord=v;updateProp(XOEvent::c_coord);}
    void setOwner(const qint8& v);
	QPoint getCoord()const{return servant ? servant->coord : QPoint();}
	qint8 getOwner()const{return servant ? servant->owner : qint8();}
	QPoint coord()const{return customValues ? customValues->coord : QPoint();}
    qint8 owner()const{return customValues ? customValues->owner : qint8(0);}
signals:
    void clicked(QPoint p);
private:
    void a_clicked(FKEvent* action);
	void c_coord(const QPoint& v){if(customValues)customValues->coord=v;}
    void c_owner(const qint8& v);
protected:
    void customInitialization();
	void customDeinitialization();
private:
    void installReferent();
    struct Servant{
        Servant():owner(NO_OWNER){}
		QPoint coord;
		qint8 owner;
	};
	struct CustomValues{
        CustomValues():owner(NO_OWNER){}
		QPoint coord;
		qint8 owner;
	};
};

#endif
